<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../img/base.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/jquery-1.8.2.min.js"></script>
<script language="javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<script language="javascript">
function checkSubmit(){
	var code = $('#code').val();
	
	if(code == 'film_id'){
		$("#code_value option").attr('selected','selected');
		
		var optionlen = $('#code_value option').length;
		
		if(optionlen == 0)
		{
			alert('电影范围不能为空');
			return false;
		}
	}
	else {
		var code_value = $('#code_value').val();
	
		if(code_value.length < 1 && code != 'all'){
			alert('范围值不能为空');
			return false;
		}
	}
	
	return true;
}

function changeValue(){
		var code_id = $('#code').val();
		var str = '';
		
		if(code_id == 'film_id'){
			$.getJSON('price_ploy_scope.php',{op:'film',ploy_id:<{$ploy_id}>},
				function(data){
					str += '<div style="float:left"><select id="source" name="source" multiple="multiple" size="6">';
					$.each(data,function(i,v){
						str += '<option value="'+v.film_id+'">'+v.film_name+'</option>';				
					});
					str += '</select></div>';	
					
					str += '<div style="float:left;width:30px;margin:0 10px;"><ul>';
					str += '<li><input type="button" class="coolbg np" value=">&nbsp;" onclick="rightValue()" /></li>';
					str += '<li><input type="button" class="coolbg np" value=">>" onclick="rightAllValue()" /></li>';
					str += '<li><input type="button" class="coolbg np" value="<&nbsp;" onclick="leftValue()" /></li>';
					str += '<li><input type="button" class="coolbg np" value="<<" onclick="leftAllValue()" /></li>';
					str += '</ul></div>';
					
					str += '<div style="float:left"><select id="code_value" name="code_value[]" multiple="multiple" size="6">';
					str += '</select></div>';
					
					$('#code_info').html(str);
				}
			);
		}else if(code_id == 'seq_no'){
			str += '<textarea id="code_value" name="code_value" rows="3" cols="80"></textarea><span style="color:#F00">* 多个场次编号请用"##"隔开</span>';
			$('#code_info').html(str);
		}else if(code_id == 'standard'){
			str += '<input type="text" name="start_code_value" id="code_value"  />到<input type="text" name="end_code_value" id="code_value"  />';
			$('#code_info').html(str);
		}else if(code_id == 'dimensional'){
			str += '<select name="code_value">';
			str += '<option value="2D">2D</option>';
			str += '<option value="3D">3D</option>';
			str += '</select>';
			$('#code_info').html(str);
		}else if(code_id == 'hall_id'){
			str += '<input type="text" name="code_value" id="code_value"  />';	
			$('#code_info').html(str);
		}else if(code_id == 'all'){
			$('#code_info').html('');
		}
}

function rightValue(){
	$("#source option:selected").appendTo($("#code_value"));
}

function rightAllValue(){
	$("#source option").appendTo($("#code_value"));	
}

function leftValue(){
	$("#code_value option:selected").appendTo($("#source"));	
}

function leftAllValue(){
	$("#code_value option").appendTo($("#source"));	
}
</script>
<style>
#code_info input {
	margin: 3px;
}
</style>
</head>
<body leftmargin='15' topmargin='10' bgcolor="#FFFFFF">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" id="head1" style="border-bottom:1px solid #CCCCCC">
	<tr>
    	<td align='center' valign='top' colspan="2">
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D1DDAA">
                <tr>
                    <td height="26" background="../img/newlinebg3.gif">
                        <table width="98%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">
                                    <input type='button' class="coolbg np" onClick="location='price_ploy_scope.php?period_id=<{$period_id}>&mc_cinemaid=<{$cinemaid}>&ploy_id=<{$ploy_id}>';" value='返回' />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
    	<td>
        	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr bgcolor="#FFFFFF">
                    <td height="4"></td>
                </tr>
            </table>
        </td>
    </tr>
  	<tr>
    	<td colspan="2">
      		<table width="800" border="0" cellpadding="0" cellspacing="0">
        		<tr>
          			<td width="84" height="24" align="center" background="../img/itemnote1.gif">&nbsp;添加范围&nbsp;</td>
          			<td width="84"></td>
          			<td>&nbsp;</td>
        		</tr>
      		</table>
    	</td>
	</tr>
</table>
<form name="form1" action="price_ploy_scope.php" enctype="multipart/form-data" method="post" onSubmit="return checkSubmit()">
<table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">

  	<tr>
    	<td height="24" colspan="4" class="bline">
      		<table width="800" border="0" cellspacing="0" cellpadding="0">
        		<tr>
                    <td width="90">&nbsp;类型：</td>
          			<td width="35%">
                    	<select name="scope_type" <{if $op == 'update'}>disabled="disabled"<{/if}>>
                            <option value="white" <{if $scope_info.scope_type == 'white'}>selected="selected"<{/if}>>白名单</option>
                            <option value="black" <{if $scope_info.scope_type == 'black'}>selected="selected"<{/if}>>黑名单</option>
                        </select>
                    </td>
                    <td width="90">&nbsp;范围：</td>
          			<td width="35%">
                    	<select id="code" name="code" onchange="changeValue()" <{if $op == 'update'}>disabled="disabled"<{/if}>>
                        <{foreach from=$code_list item=code key=key}>
                        	<option value="<{$key}>" <{if $scope_info.scope_code == $code.code_id}>selected="selected"<{/if}>><{$code}></option>
                        <{/foreach}>
                        </select>
                    </td>
        		</tr>
      		</table>      
    	</td>
  	</tr>

    <tr>
    	<td height="24" class="bline">
      		<table width="800" border="0" cellspacing="0" cellpadding="0">
                <tr>
          			<td width="78" >&nbsp;范围值：</td>
          			<td width="722" id="code_info">
                    
                    </td>
                </tr>
      		</table>      
    	</td>
  	</tr>
</table>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    	<td height="56">
			<table width="98%" border="0" cellspacing="1" cellpadding="1">
        		<tr>
          			<td align="center">
          				<table width="214" border="0" cellspacing="0" cellpadding="0" >
              				<tr>
				                <td width="115">
                                	<input type="hidden" name="period_id" value="<{$period_id}>" />
                                	<input type="hidden" name="op" value="save" />
                                	<input type="hidden" name="mc_cinemaid" value="<{$cinemaid}>" />
                                    <input type="hidden" name="ploy_id" value="<{$ploy_id}>" />
				                    <input name="imageField" type="image" src="../img/button_ok.gif" width="60" height="22" class="np" border="0"  style="cursor:pointer; ">
				                </td>
				                <td width="99">
				                	<img src="../img/button_reset.gif" width="60" height="22" border="0" onClick="location.reload();" style="cursor:pointer; ">
				                </td>
			              	</tr>
						</table>
					</td>
    			</tr>
			</table>
		</td>
	</tr>
</table>
</form>
</body>

</html>